import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '楼栋',
    align:"center",
    dataIndex: 'buildName'
   },
   {
    title: '楼层',
    align:"center",
    dataIndex: 'storeyName'
   },
   {
    title: '房间',
    align:"center",
    dataIndex: 'roomCode'
   },
   {
    title: '床铺',
    align:"center",
    dataIndex: 'bedId_dictText'
   },
   {
    title: '人员姓名',
    align:"center",
    dataIndex: 'personId_dictText'
   },
   {
    title: '入住日期',
    align:"center",
    dataIndex: 'checkinDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '离开日期',
    align:"center",
    dataIndex: 'leaveDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '离开原因',
    align:"center",
    dataIndex: 'leaveReason'
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status',
    customRender:({text}) =>{
      return !text?"":(text=='0'?'停用':'启用')
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "所属部门",
      field: 'sysOrgCode',
      component: 'JSelectDept',
      //colProps: {span: 6},
 	},
   {
    label: "人员姓名",
    field: 'personName',
    component: 'Input',
    // component: 'JDictSelectTag',
    // componentProps:{
    //     dictCode:"ss_person,name,id"
    // },
    //colProps: {span: 6},
 },
	/*
	{
      label: "床铺",
      field: 'bedId',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"dorm_bed,bed_code,id"
      },
      //colProps: {span: 6},
 	},
	*/
	
];
//表单数据
export const formSchema: FormSchema[] = [
  // {
  //   label: '楼栋',
  //   field: 'buildId',
  //   component: 'JDictSelectTag',
  //   slot: 'buildSlot'
  // },
  // {
  //   label: '楼层',
  //   field: 'storeyId',
  //   component: 'JDictSelectTag',
  //   slot: 'storeySlot'
  //   // componentProps:{
  //   //     dictCode:"dorm_storey,storey_name,id"
  //   //  },
  // },
  {
    label: '房间号',
    field: 'roomCode',
    // component: 'Input',
    component: 'JDictSelectTag',
    slot: 'roomSlot'
  },
  {
    label: '床铺',
    field: 'bedId',
    component: 'JDictSelectTag',
    slot: 'bedSlot',
    componentProps:{
      // disable:true
    //     dictCode:"dorm_bed,bed_code,id"
     },
  },
  {
    label: '人员',
    field: 'personId',
    required: true,
    component: 'JSelectPerson',
    componentProps: {
      labelKey: 'name',
      isRadioSelection: true
    },
    // component: 'JDictSelectTag',
    // componentProps:{
    //     dictCode:"ss_person,name,id"
    //  },
  },
  {
    label: '入住日期',
    field: 'checkinDate',
    component: 'DatePicker',
  },
  {
    label: '状态',
    field:"status",
    component: 'JDictSelectTag',
    defaultValue:'1',
	  show: false,
    componentProps:{
       options: [
        { label: '启用', value: '1' },
        { label: '停用', value: '0' },
       ],
     },
   },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//表单数据
export const leaveSchema: FormSchema[] = [
  
  {
    label: '人员',
    field: 'personId',
    required: true,
    component: 'JSelectPerson',
    dynamicDisabled:true,
    componentProps: {
      labelKey: 'name',
      isRadioSelection: true
    }
  },
  {
    label: '入住日期',
    field: 'checkinDate',
    dynamicDisabled:true,
    component: 'DatePicker',
  },
  {
    label: '离开日期',
    field: 'leaveDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入离开日期!'},
          ];
     },
  },
  {
    label: '离开原因',
    field: 'leaveReason',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入离开原因!'},
          ];
     },
  },
  {
    label: 'status',
    field: 'status',
    component: 'Input',
    defaultValue:'0',
	  show: false
  },
  {
    label: '状态',
    field:"status",
	  show: false,
    component: 'JDictSelectTag',
    defaultValue:'0',
    dynamicDisabled:true,
    componentProps:{
       options: [
        { label: '启用', value: '1' },
        { label: '停用', value: '0' },
       ],
     },
   },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: 'id',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  bedId: {title: '床铺',order: 1,view: 'number', type: 'number',dictTable: 'dorm_bed', dictCode: 'id', dictText: 'bed_code',},
  personId: {title: '人员',order: 2,view: 'number', type: 'number',dictTable: 'ss_person', dictCode: 'id', dictText: 'name',},
  checkinDate: {title: '入住日期',order: 3,view: 'date', type: 'string',},
  leaveDate: {title: '离开日期',order: 4,view: 'date', type: 'string',},
  leaveReason: {title: '离开原因',order: 5,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}